﻿using System;

namespace Sencha.Serialization.Contracts
{
	public abstract class MetadataInterpreter
	{
		public static readonly MetadataInterpreter DataContract = new DataContractInterpreter();
		public static readonly MetadataInterpreter Default = DataContract;

		public abstract TypeDescription Interpret(DataContract contract, MetadataDescriber descriptor, Type contractedType);

		protected void AddTypeInfoToContract(DataContract contract, TypeDescription typeInfo)
		{
			if (contract == null)
				throw new ArgumentNullException("contract");
			if (typeInfo == null)
				throw new ArgumentNullException("typeInfo");

			contract.AddTypeInfo(typeInfo);
		}
	}
}
